<?php
/**
 * Description of Emms_Report_Disbursements
 *
 * @author andres
 */
class Emms_Report_Disbursements extends HTech_Report
{
    protected function _setName() 
    {
        $this->_name = $this->translate('Loan disbursements');
    }

    protected function _setForm() 
    {
        $this->_form = new HTech_Report_Form_DateRange();
    }
    
    protected function _setIndex() {}

    protected function _setSql() 
    {
        $this->_sql = '
            select 
                *
            from 
                view_loans
            where 
                DeliveryDate >= :dateFrom and 
                DeliveryDate <= :dateTo';
    }
    
    protected function _setHeaders()
    {
        $this->_headers = new stdClass();
        $this->_headers->LoanId = $this->translate('Loan Id');
        $this->_headers->LoanMasterId = $this->translate('Master Id');
        $this->_headers->CheckNumber = $this->translate('Check number');
        $this->_headers->LoanCycle = $this->translate('Loan cycle');
        $this->_headers->LoanCycleByLine = $this->translate('Loan cycle by line');
        $this->_headers->LoanCycleByProgram = $this->translate('Loan cycle by program');
        $this->_headers->LoanCycleByProduct = $this->translate('Loan cycle by product');
        $this->_headers->BorrowerType = $this->translate('Borrower type');
        $this->_headers->GroupName = $this->translate('Group');
        $this->_headers->ClientId = $this->translate('Client Id');
        $this->_headers->ClientCode = $this->translate('Client code');
        $this->_headers->ClientCodeType = $this->translate('Client code type');
        $this->_headers->ClientFullName = $this->translate('Client name');
        $this->_headers->ClientNickName = $this->translate('Nickname');
        $this->_headers->ClientGender = $this->translate('Gender');
        $this->_headers->ClientHomePhone = $this->translate('Home phone');
        $this->_headers->ClientMobilePhone = $this->translate('Mobile phone');
        $this->_headers->BusinessName = $this->translate('Business name');
        $this->_headers->BusinessType = $this->translate('Business type');
        $this->_headers->BusinessActivity = $this->translate('Activity');
        $this->_headers->LoanProductName = $this->translate('Loan product');
        $this->_headers->ProductLine = $this->translate('Line');
        $this->_headers->ProgramName = $this->translate('Program');
        $this->_headers->FundName = $this->translate('Fund');
        $this->_headers->LocationShortName = $this->translate('Branch');
        $this->_headers->Community = $this->translate('Community');
        $this->_headers->CommunityType = $this->translate('Community type');
        $this->_headers->OfficerUsername = $this->translate('Officer');
        $this->_headers->DeliveryDate = $this->translate('Disbursement date');
        $this->_headers->ExpectedCancelDate = $this->translate('Expected paid date');
        $this->_headers->CancelDate = $this->translate('Actual paid date');
        $this->_headers->Status = $this->translate('Current Status');
        $this->_headers->PaymentFrequency = $this->translate('Payment Freq.');
        $this->_headers->Installments = $this->translate('Installments');
        $this->_headers->PaymentMnt = $this->translate('Payment quota');
        $this->_headers->VoluntarySavings = $this->translate('Voluntary savings');
        $this->_headers->MandatorySavings = $this->translate('Mandatory savings');
        $this->_headers->Principal = $this->translate('Principal');
        $this->_headers->LoanInsuranceMnt = $this->translate('Loan insurance');
        $this->_headers->HealthInsuranceMnt = $this->translate('Health insurance');
        $this->_headers->AdministrativeFeeMnt = $this->translate('Admin. fee');
        $this->_headers->InterestCalculation = $this->translate('Interest method');
        $this->_headers->AnnualPercentageRate = $this->translate('Annual pct. rate');
        $this->_headers->LoanInsurancePct = $this->translate('Loan insurance pct. rate');
        $this->_headers->HealthInsurancePct = $this->translate('Health insurance pct. rate');
        $this->_headers->AdministrativeFeePct = $this->translate('Admin. fee pct. rate');
        $this->_headers->PrincipalGraceRate = $this->translate('Principal grace rate');
        $this->_headers->PrincipalGraceMargin = $this->translate('Principal grace margin');
        $this->_headers->DelayPenaltyRate = $this->translate('Delay penalty rate');
        $this->_headers->DelayPenaltyFixedCharge = $this->translate('Delay penalty fixed charge');
        $this->_headers->DelayGrace = $this->translate('Delay grace');
        $this->_headers->BalancePrincipal = $this->translate('Principal current balance');
        $this->_headers->BalanceLoanInsurance = $this->translate('Loan insurance current balance');
        $this->_headers->BalanceHealthInsurance = $this->translate('Health insurance current balance');
        $this->_headers->BalanceAdministrativeFee = $this->translate('Admin. fee current balance');
    }
    
    public function setParams($params) 
    {
        $this->_params = array(
            ':dateFrom' => $params['DateFrom'],
            ':dateTo' => $params['DateTo']);
    }

}
